package com.mvc.utils;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

public class FullForm {

	public FullForm() {
	}

	public static ActionForm full(String formPath, HttpServletRequest request) {
		ActionForm actionForm = null;
		try {
			Class<?> clazz = Class.forName(formPath);
			actionForm = (ActionForm) clazz.newInstance();
			Field[] fields = clazz.getDeclaredFields();
			for (Field field : fields) {
				field.setAccessible(true);
				field.set(actionForm, request.getParameter(field.getName()));
				field.setAccessible(false);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return actionForm;
	}
}
